/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { Request, Response } from 'express';
import { ResponseItem, responseSuccess } from '../utils';
import Mock, { mock } from 'mockjs';

export default {
  'POST /jdk/gxdDkh/list': (req: Request, res: Response) => {
    const data = Mock.mock({
      'list|1-30': [
        {
          id: '@id',
          user_id: '@id',
          nickname: '徐肖磊测试环境账号',
          avatar_url:
            'http://judanke.oss-cn-hangzhou.aliyuncs.com/cd/public/2022/08/04/144602107928.jpeg',
          phone: '15837899712',
          password: '$2y$10$jBUCdi9OaveErWqbgphQ9unrLy.wlsgIm/6QbduDiFiVbJjSabfDS',
          type: '2',
          is_slave: '0',
          parent_id: '0',
          league_id: '124322289',
          'league_source|1': ['0', '1', '2'],
          league_remark: 't上海聚单客01',
          created_at: '2022-06-02 13:43:57',
          league_time: '2022-09-15 11:04:56',
          updated_at: '2022-09-28 16:28:19',
          last_login_at: '2022-09-28 16:28:19',
          is_deleted: '0',
          delivery_status: '1',
          deleted_at: null,
          invite_staff_id: '0',
          is_black: '0',
          league_name: '徐肖磊加盟商（测试环境在用）',
          shop_count: '27',
          'delivery_count|1-100': 100,
          'gxd_delivery_count|1-100': 100,
          order_count: '323',
          address_detail: '上海市上海市长宁区',
          shop_cates: '文件证件、快餐水果',
          shop_cate_ids: '2,3',
          open_id: '636363',
          account: '15732029824',
          account_level: '2',
          address: [
            ['330000000000', '330100000000', '330105000000'],
            ['310000000000', '310000000000', '310104000000'],
          ],
          address_name: [
            {
              province: '上海市',
              city: '上海市',
              district: ['长宁区', '普陀区'],
            },
            {
              province: '北京市',
              city: '北京市',
              district: ['东城区'],
            },
          ],
          city: '@city()',
        },
      ],
    });
    const result: ResponseItem = {
      code: 0,
      msg: '成功',
      data: {
        ...data,
        total: data.list.length,
      },
    };
    return res.json(result);
  },
  'POST /jdk/gxdDkh/searchUser': (req: Request, res: Response) => {
    return res.json({
      code: 0,
      data: {
        address: '商户地址',
        nickname: '昵称',
        phone: '13783636923',
      },
      msg: 'success',
    });
  },
  'POST /jdk/gxdDkh/add': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/gxdDkh/del': (req: Request, res: Response) => responseSuccess(req, res),
  'POST /jdk/gxdDkh/deliveryAccountList': (req: Request, res: Response) => {
    return res.json(
      mock({
        code: 0,
        'data|5': [
          {
            'id|+1': 1,
            access_token: '',
            created_at: '@datetime()',
            delivery_brand: 'gxd',
            'account_level|1': ['1', '2', '3'],
            'open_id|1000-9999': 3200,
            status: '1',
            updated_at: '@datetime()',
            account_remark: '备注',
          },
        ],
        msg: '成功',
      }),
    );
  },
  'POST /jdk/gxdDkh/accountCityList': (req: Request, res: Response) => {
    return res.json(
      mock({
        code: 0,
        'data|5': [
          {
            city: '@city()',
          },
        ],
        msg: '成功',
      }),
    );
  },
};
